﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;

namespace OverStore.Runtime.ObjectRepository.CallbackManager
{
    /// <summary>
    /// <para>
    ///     Describes actions are performed over object due persisting cycle.
    /// </para>
    /// <para>
    ///     Action are performed in following order. Cancellable actions are enclosed in square brackets.
    ///         * Object loading: [Loading], AcceptingChanges, Loaded
    ///         * Object saving (unchanged object): [Saving], Saved
    ///         * Object saving (new object): [Saving], [Persisting], Inserting, Inserted, Persisted, Saved  
    ///         * Object saving (modified object): [Saving], [Persisting], Updating, Updated, Persisted, Saved  
    ///         * Object saving (object marked as deleted): [Saving], [Persisting], Deleting, Deleted, Persisted, Saved
    ///         * Marking object as deleted: MarkingAsDeleted
    ///         * Adding object: Adding
    ///         * Attaching object: Attaching
    /// </para>
    /// </summary>
    public enum PersistenceOperation
    {
        /// <summary>
        /// Loading data in object is started.
        /// </summary>
        Loading,
        /// <summary>
        /// Loading data in object completed.
        /// </summary>
        Loaded,
        /// <summary>
        /// Object data saving started. 
        /// Callback with this operation is called even when object data are not actually 
        /// changed and will not be writed into storage.
        /// </summary>
        Saving,
        /// <summary>
        /// Object data saving completed.
        /// Callback with this operation is called even when object data were not writed into storage.
        /// </summary>
        Saved,
        /// <summary>
        /// Object data are intended to be writed into data storage. Returning false from this callback cancels persisting object data.
        /// </summary>
        Persisting,
        /// <summary>
        /// Object data were writed into data storage.
        /// </summary>
        Persisted,
        /// <summary>
        /// Object is marked as deleted.
        /// </summary>
        MarkingAsDeleted,
        /// <summary>
        /// Object is added.
        /// </summary>
        Adding,
        /// <summary>
        /// Object data is going to be inserted in the table.
        /// </summary>
        Inserting,
        /// <summary>
        /// Object data were successfuly inserted in the table.
        /// </summary>
        Inserted,
        /// <summary>
        /// Object data is going to be updated in the table.
        /// </summary>
        Updating,
        /// <summary>
        /// Object data were updated in the table.
        /// </summary>
        Updated,
        /// <summary>
        /// Object data is going to be deleted from the table.
        /// </summary>
        Deleting,
        /// <summary>
        /// Object data were deleted from the table.
        /// </summary>
        Deleted,
        /// <summary>
        /// Object attached to session.
        /// </summary>
        Attaching,
        /// <summary>
        /// Object is about to be saved, but object data is not changed.
        /// </summary>
        NotModified,
    }
}
